﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AllotCityUser_Form.aspx.cs" Inherits="FS.Web.BLL.Visa_Base.AllotCityUser_Form" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>分配按钮</title>
    <link href="/Themes/Scripts/EasyUI/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/EasyUI/jquery.easyui.min.js" type="text/javascript"></script> 
    <script type="text/javascript">
        $(function () {
            var city = GetQuery("cityid");              
            $('#Cityid_Hidden').val(city);

            reload();
        })

        function Fadd() {
            var nodes = $('#tt1').tree('getChecked');
            var s = '';
            for (var i = 0; i < nodes.length; i++) {
                if (s != '') s += ',';
                s += nodes[i].id;
            }            
            if (s == '') {
                alert("请先选择要添加的用户!");
                return false;
            }
            else {
                var cityid=$('#Cityid_Hidden').val();
                var parm = 'action=add&id=' + escape(s) + '&cityid=' + escape(cityid);                
                getAjax('CityUser.ashx', parm, function (rs) {
                    if (parseInt(rs) > 0) { 
                        reload();
                    } else if (parseInt(rs) == 0) {
                        showTipsMsg("用户已经添加，请检查！", 3000, 3);
                    }
                    else {
                        showTipsMsg("<span style='color:red'>添加失败，请稍后重试！</span>", 4000, 5);
                    }
                });
            }
        }

        function FDel() {
            var nodes = $('#tt2').tree('getChecked');
            var s = '';
            for (var i = 0; i < nodes.length; i++) {
                if (s != '') s += ',';
                s += nodes[i].id;
            }            
            if (s == '') {
                alert("请先选择要删除的用户!");
                return false;
            }
            else {
                var delparm = 'action=delete&id=' + s;
                DeleteData('/BLL/Visa_Base/CityUser.ashx', delparm)                
                reload();
            }
        }

        function reload() {
            var cityid=$('#Cityid_Hidden').val();
            $('#tt2').tree({
                url: '/BLL/Visa_Base/CityUser.ashx?action=GetCityUser&cityid=' + cityid,
                method: 'get',
                checkbox:true
            });
            $('#tt2').tree('reload');
        }
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input id="Cityid_Hidden" type="hidden" runat="server" />
    <div id="Buttonlist">
        <div id="Buttonlistleft" style="float: left; width: 48.6%; border: 1px solid #ccc; margin-right: 5px;">
            <div class="box-title" style="height: 25px;">
                所有用户;
                <a class="l-btn" href="javascript:void(0)" onclick="return Fadd();"><span class="l-btn-left">
                    <img src="/Themes/Images/16/add.png" alt="" />添 加</span></a>
            </div>
            <div class="easyui-panel" style="padding:5px;overflow: auto;overflow-x: hidden; overflow-y: scroll;
                margin-bottom: 5px;width:95% ;height:340px">
		        <ul id="tt1" class="easyui-tree" data-options="url:'/BLL/Visa_Base/CityUser.ashx?action=GetAllUser',
                    method: 'get',checkbox:true"></ul>
	        </div>            
        </div>
        <div id="Buttonlistright" style="float: left; width: 48.6%; border: 1px solid #ccc;">
            <div class="box-title" style="height: 25px;">
                已选用户;                
                <a class="l-btn" href="javascript:void(0)" onclick="return FDel();"><span class="l-btn-left">
                    <img src="/Themes/Images/16/delete.png" alt="" />删 除</span></a>

            </div>
           <div class="easyui-panel" style="padding:5px;overflow: auto;overflow-x: hidden; overflow-y: scroll;
                margin-bottom: 5px;width:95% ;height:340px">
		        <ul id="tt2" class="easyui-tree"></ul>
	        </div> 
        </div>
    </div>
    </form>
</body>
</html>
